﻿namespace B.S.AuthCenter.Common
{
    /// <summary>
    /// 扩展类
    /// 用this作为类型扩展的关键字
    /// 类和方法必须是静态的
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// 把字符串转换成数字
        /// </summary>
        /// <param name="str">this重点</param>
        /// <returns></returns>
        public static int Toint32(this string? str)
        {
            if(str==null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(str);
            }
        }
        /// <summary>
        /// 根据身份证计算出生年月日
        /// </summary>
        /// <param name="carId">身份证号</param>
        /// <returns></returns>
        public static string GetBirthByCarId(this string carId)
        {
            string result = carId.Substring(6, 8);
            return result;
        }
        public static string GetDate(this DateTime dates)
        {
           return dates.ToString("YYYY年mm月dd日");
            
        }
    }
}
